/*
 * @description: 
 * @Date: 2022-10-13 16:28:07
 * @LastEditTime: 2022-10-15 23:54:56
 */
import jsencrypt from 'jsencrypt';


const encode = (text) => {
  const rsa = new jsencrypt();
  rsa.setPublicKey(`
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDtGeATkbnSgdtU/DHErpFMyvge
LbFs4rWVJhnMgS/MnUkbJ+ukUIz+IMX9czl2o6YjZTPOUo63PwwjSh0nT5DHnMXD
Ly9yxIPW0hq/P00QRmOm1ZZylMUbCNrLs+hHSTTvXK5u0WxN6mMoiU2E0Ktv5EeK
gZs+DVE0/84i9E/QSwIDAQAB
-----END PUBLIC KEY-----`)
  if (text) {
    return rsa.encrypt(text)
  }
}

const decode = (text) => {
  const rsa = new jsencrypt();
  rsa.setPrivateKey(`-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANcptlbgATXF87X1
GEywTRHYLE9RAg0Q+pY7D6JedbBOmd9pXnPDTWzVi+3NJ4wJfdZxjpSYMIz+Pg7N
A+yx+MSce3zJuJT3bwIo29lkI0BQqlFPTr2mGT2G8eN8xOFmHYxxCc/pFaPc0Jbx
1OM4WakdXs0PGTJxtvobRT1W9A3NAgMBAAECgYBz1IfN0v+zxCJENXLkbhC/Z4HL
HVAeWqKcV6U+At4WkOnzRNVNOrmmunt/BG+iysVMuYtJYXjZnlEoRKQ1O0YxDK01
Aiz5pk+UIi64PyvoTL0xwNmquWmvkCSxelp+fS0ubHtzLvtrz8ZPR6EpWKekXYuB
jq+2tTjlI6ZG3guEPQJBAPzCzB6MBPKkACpYJlZ3djQGrGo/HrmzpjD3Lti7m4dC
t4F9M4tQ8+aMidmXkqunOnCKj1+0p7CSiph+C2pNmLcCQQDZ65JZpTtLlMe+mN6R
kBNG6MaoIQutHTDPNDZg1MFC/2ey2n4BALmpcCck7zJHXZ+qne3Hw4cgfUwtYtj9
/yGbAkEA3SyLtpMpZTTy3BrEeVcRfNb2GgZfmXnFDAXP3WDU6FgOAWYQK3FL60rA
+UEz27Z6Ya4tZT7MmaqxUlzBGmUKIwJAIoZm7lr2NPhCWRkBEhDAbRiN+K8bmXap
d/purxKl98ZdGIHzOpdx0r1ZBkn7LkFP/Yj91gtNSkFvozUo6bzVBwJBAJmq4B3U
7IVQv2lI3DzZga2BREl4+jZkqspfpReUj79cg7AEqA04qbzpkogoJUSU5fsWvvux
g/GE1QP47C7Vhyo=
-----END PRIVATE KEY-----`)
  if (text) {
    return rsa.decrypt(text)
  }
}

export { encode, decode }

